home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 for Intel / NeXTSTEP 3.2 for Intel.iso / NextLibrary / Documentation / Sybase / DBLIB / Intro.nr < prev    next >
Encoding:
Text File  |  1993-04-22  |  52.5 KB  |  1,422 lines

  1. .Ds U
  2. .Pt Section
  3. .Ff 1 "Introduction" "\*L Reference Manual"
  4. .H1 "Overview of \*L"
  5. .Ih "\*L, overview of"
  6. .Ih "\*L, contents of"
  7. .Ss \*L TM
  8. is a set of C routines and macros that allow your
  9. application to interact with the 
  10. .Ss \*S TM .
  11. It includes routines that send 
  12. .Ss \*N TM
  13. commands
  14. to the \*S and others that process the results of those commands.
  15. Other routines handle error conditions, perform data
  16. conversion, and provide a variety of information about 
  17. the interaction with the \*S.
  18. \*L also contains several header files
  19. that define structures and values used by the routines.
  20. Versions of \*L have been developed for a number
  21. of languages besides C, including COBOL, FORTRAN, Ada, and 
  22. Pascal.
  23. .H2 "\*N"
  24. .Ih "\*N"
  25. .Ih "SQL database language"
  26. \*N is the enhanced SYBASE\(rg version of the SQL
  27. database language.
  28. The application uses it to communicate with the \*S.
  29. \*N provides commands for creating and
  30. manipulating database objects, as well as for 
  31. inserting, updating, and selecting data.
  32. The SYBASE enhancements include data integrity features and
  33. stored procedures.
  34. .Ih "stored procedures, \*N"
  35. .Ih "procedures, stored, \*N"
  36. Stored procedures allow much of an application's
  37. processing logic to be shifted from the application
  38. proper to the \*S.
  39. They can contain most \*N
  40. statements, including \*N
  41. control-of-flow statements.
  42. Furthermore, stored procedures are pre-compiled, so
  43. the statements don't have to be parsed each time the 
  44. procedure is executed.
  45. .H2 "Applications for \*L"
  46. .Ih "applications, \*L"
  47. .Ih "\*L applications"
  48. \*L enables the database to become an integral
  49. part of an application.
  50. \*N statements can be incorporated into the
  51. application, allowing the application to retrieve and
  52. update values from a database.
  53. Through \*L, values from the database can
  54. be placed in program variables for manipulation by the
  55. application.
  56. Conversely, values in program variables can be inserted
  57. into the database.
  58. .LP
  59. Although \*L contains a large number of routines,
  60. giving the application a great deal of control over its
  61. interaction with the \*S, most applications require only
  62. a few of the routines.
  63. The actual process of connecting with the \*S, sending 
  64. \*N commands to the \*S, and processing the resulting data
  65. is simple and straightforward.
  66. .H2 "Comparing the Library Approach to Embedded SQL"
  67. The \*L approach is distinctly different from the ``embedded SQL'' 
  68. type of host language interface that some database management systems
  69. provide.
  70. In contrast to an embedded SQL interface, the
  71. \*L interface does not require a host language pre-compiler.
  72. Avoiding preprocessing in this way makes applications
  73. involving a database more straightforward to write and to debug.
  74. The \*L routines are ordinary C routines and are not
  75. preprocessed into some intermediate form.
  76. .H2 "Other SYBASE Development Tools"
  77. .Ih "SYBASE development tools"
  78. .Ih "tools, development"
  79. .Ih "development tools, SYBASE"
  80. SYBASE provides a complete development environment.
  81. In addition to control over database access through
  82. \*L, SYBASE offers optional tools for creating forms-based,
  83. event-driven applications.
  84. These tools are 
  85. .Ss \*A TM
  86. and the 
  87. .Ss \*F TM
  88. set of routines.
  89. .Ih "\*F"
  90. \*A is an editor for creating forms and specifying event-driven
  91. processing.
  92. .Ih "\*A editor"
  93. .Ih "editor, \*A"
  94. \*F is a set of C routines that support forms-based, event-driven
  95. processing.
  96. Just as \*L routines provide an application with access to the \*S and database objects,
  97. \*F routines provide access to the form and its objects.
  98. A forms-based application typically contains both 
  99. \*F and \*L routines.
  100. For more information, see the \f2\*A User's Guide\f1 and the \f2\*F Reference Manual\f1.
  101. .H1 "Communicating with the \*S"
  102. \*L routines communicate with the \*S through the 
  103. DBPROCESS structure.
  104. Through the DBPROCESS, commands are sent to the \*S and query results are returned to the application.
  105. .Ih "DBPROCESS structure"
  106. .Ih "\*S, communicating with"
  107. One of the first routines an application typically calls is \f2dbopen()\f1,
  108. which logs the application into a \*S and allocates and initializes a DBPROCESS.
  109. .Ih "dbopen"
  110. This DBPROCESS then serves as the connection between the application and the \*S.
  111. Most \*L routines require a DBPROCESS as the first parameter.
  112. .LP
  113. An application can have multiple open DBPROCESSes, connected to one or more \*Ss.
  114. .Ih "DBPROCESSes, multiple"
  115. .Ih "\*Ss, multiple"
  116. .Ih "multiple \*Ss"
  117. For instance, an application that has to
  118. perform database updates in the midst of processing
  119. the results of a query needs a separate DBPROCESS for each task.
  120. As another example, 
  121. to select data from one \*S and update a database on another \*S,
  122. an application needs two DBPROCESSes\(emone for each \*S.
  123. Each DBPROCESS in an application functions independently of any other DBPROCESS.
  124. .Ih "DBPROCESSes, multiple"
  125. .LP
  126. The DBPROCESS structure points to a command buffer that contains \*N
  127. commands for transmission to the \*S.
  128. .Ih "command buffer"
  129. .Ih "buffer, command"
  130. It also points to result rows returned from the \*S\(emeither single rows or buffers
  131. of rows if buffering has been specified.
  132. .Ih "result rows"
  133. .Ih "rows, result"
  134. In addition, it points to a message buffer that contains error and informational
  135. messages returned from the \*S.
  136. .Ih "message buffer"
  137. .Ih "buffer, message"
  138. .LP
  139. The DBPROCESS also contains a wealth of information on various aspects of \*S interaction.
  140. Many of the \*L routines deal with extracting information from
  141. the DBPROCESS.
  142. Applications should access and manipulate components of the DBPROCESS structure only
  143. through \*L routines, and not directly.
  144. .LP
  145. One other important structure is the LOGINREC.
  146. .Ih "LOGINREC structure"
  147. .Ih "login record"
  148. .Ih "record, login"
  149. It contains typical login information, such as the username and password, 
  150. which the \f2dbopen()\f1 routine uses when logging into a \*S.
  151. \*L routines can specify the information in the LOGINREC.
  152. .H1 "\*L Programming"
  153. .Ih "programming with \*L"
  154. .Ih "\*L programming, steps involved"
  155. Programming with \*L typically involves a few basic steps:
  156. .Bl "1."
  157. Logging into a \*S.
  158. .Bl "2."
  159. Placing \*N commands into a buffer and sending them to the \*S.
  160. .Bl "3."
  161. Processing the results, if any, returned from the \*S, one command
  162. at a time and one result row at a time.
  163. The results can be placed in program variables, where
  164. they can be manipulated by the application.
  165. .Bl "4."
  166. Handling \*L errors and \*S messages.
  167. .Bl "5."
  168. Closing the connection with the \*S.
  169. .Bz
  170. The example below shows the basic framework of many
  171. \*L applications.
  172. .Ih "\*L program, framework of"
  173. .Ih "program, \*L"
  174. The program opens a connection to a \*S, sends a \*N SELECT
  175. command to the \*S, and processes the set of rows
  176. resulting from the SELECT.
  177. For brevity's sake, this program does not include the
  178. error or message handling routines;
  179. those routines are illustrated in the example programs in
  180. the \f2\*L Reference Supplement\f1.
  181. .SD
  182. .ps -2
  183. .vs -2
  184. .in +3n
  185. .ta +4n +4n +4n +4n +4n +4n +4n
  186. .ne 5
  187. #include <sybfront.h>
  188. #include <sybdb.h>
  189. #include <syberror.h>
  190.  
  191. /* Forward declarations of the error handler and message handler. */
  192. int             err_handler();
  193. int             msg_handler();
  194.  
  195. main()
  196. {
  197.     DBPROCESS     *dbproc;       /* The connection with the \*S. */
  198.     LOGINREC      *login;        /* The login information. */
  199.     DBCHAR         name[40];
  200.     DBCHAR         city[20];
  201.  
  202.     /* Initialize DB-Library. */
  203. .mc |
  204.     if (dbinit() == FAIL)
  205.         exit(ERREXIT);
  206.  
  207. .mc
  208.     /* 
  209.     ** Install user-supplied error-handling and message-handling routines.
  210.     ** The code for these is omitted from this example for conciseness.
  211.      */
  212.     dberrhandle(err_handler);
  213.     dbmsghandle(msg_handler);
  214.  
  215.     /* Get a LOGINREC.  */
  216.     login = dblogin();
  217.     DBSETLPWD(login, "server_password");
  218.     DBSETLAPP(login, "example");
  219.  
  220.     /* Get a DBPROCESS structure for communication with the \*S. */
  221.     dbproc = dbopen(login, NULL);
  222.  
  223.     /*
  224.     ** Retrieve some columns from the "authors" table in the
  225.     ** "pubs" database.
  226.     */
  227.  
  228.     /* First, put the command into the command buffer. */
  229.     dbcmd(dbproc, "select au_lname, city from pubs..authors");
  230.     dbcmd(dbproc, " where state = 'CA' ");
  231.  
  232.     /* Send the command to the \*S and start execution. */
  233.     dbsqlexec(dbproc);
  234.  
  235.     /* Process the command. */
  236.     if (dbresults(dbproc) == SUCCEED)
  237.     {
  238.         /* Bind results to program variables. */
  239.         dbbind(dbproc, 1, STRINGBIND, (DBINT)0, name);
  240.         dbbind(dbproc, 2, STRINGBIND, (DBINT)0, city);
  241.  
  242.         /* Retrieve and print the result rows. */
  243.         while (dbnextrow(dbproc) != NO_MORE_ROWS)
  244.         {
  245.             printf ("%s: %s\en", name, city);
  246.         }
  247.     }
  248.  
  249.     /* Close the connection to the \*S. */
  250.     dbexit();
  251. }
  252. .in -3n
  253. .ED
  254. .ps +2
  255. .vs +2
  256. .LP
  257. The example illustrates features common to most \*L
  258. applications:
  259. .Bl
  260. \f3Header files\f1.
  261. .Ih "header files"
  262. .Ih "include files"
  263. .Ih "files, header"
  264. .Ih "files, include"
  265. Two header files, \f2sybfront.h\f1 and \f2sybdb.h\f1,
  266. .Ih "sybfront.h"
  267. .Ih "sybdb.h"
  268. are required in all source files that contain calls to
  269. \*L routines.
  270. \f2sybfront.h\f1 must appear first in the file.
  271. It defines symbolic constants such as function return values, 
  272. described in the Section 2 manual pages, and the
  273. exit values STDEXIT and ERREXIT.
  274. .Ih "symbolic constants"
  275. .Ih "constants, symbolic"
  276. .Ih "STDEXIT"
  277. .Ih "ERREXIT"
  278. These exit values can be used as the argument for
  279. the C standard library function \f2exit()\f1.
  280. Since they are defined appropriately for the operating
  281. system running the program,
  282. their use provides a system-independent approach to exiting
  283. the program.
  284. \f2sybfront.h\f1 also includes typedefs for datatypes that can be used in 
  285. program variable declarations.
  286. These datatypes are described a little later.
  287. .sp 0.5v
  288. \f2sybdb.h\f1 contains additional definitions and typedefs, most of which are meant
  289. to be used only by the \*L routines and should not be directly accessed
  290. by the program.
  291. Of chief importance in \f2sybdb.h\f1 is the typedef for the DBPROCESS structure.
  292. As discussed earlier, the DBPROCESS structure should be manipulated
  293. only through \*L routines; you should not access its components directly.
  294. To ensure compatibility with future releases of \*L, 
  295. use the contents of \f2sybdb.h\f1 only as documented in the \*L manual pages.
  296. .sp 0.5v
  297. The third header file in the example, \f2syberror.h\f1, contains error severity
  298. values and should be included if the program refers
  299. to those values.
  300. .Ih "syberror.h"
  301. .mc |
  302. .Bl
  303. \f3dbinit()\f1.
  304. .Ih "dbinit"
  305. This routine initializes \*L.
  306. It must be the first \*L routine in the program.
  307. Not all \*L environments currently require the \f2dbinit()\f1 call.
  308. However, to ensure future compatibility and portability, you should
  309. include this call at the start of all \*L programs.
  310. .mc
  311. .Bl
  312. \f3dberrhandle() and dbmsghandle()\f1.
  313. .Ih "dberrhandle"
  314. .Ih "dbmsghandle"
  315. .Ih "error handling"
  316. .Ih "message handling"
  317. .Ih "errors, \*L"
  318. .Ih "errors, \*S"
  319. .Ih "\*L errors"
  320. .Ih "\*S errors"
  321. \f2dberrhandle()\f1 installs a user-supplied error-handling routine, which
  322. gets called automatically whenever the application encounters
  323. a \*L error.
  324. Similarly, \f2dbmsghandle()\f1 installs a message-handling routine, which
  325. gets called in response to informational or error messages returned from the \*S.
  326. The error and message handling routines are user-supplied.
  327. Sample handlers have not been supplied with this example, but are included at the end
  328. of each example program in 
  329. the \f2\*L Reference Supplement\f1.
  330. .Bl
  331. \f3dblogin()\f1.
  332. .Ih dblogin
  333. .Ih LOGINREC
  334. This routine supplies a LOGINREC structure, which \*L will use to log into a \*S.
  335. The two macros that follow set certain components of the LOGINREC.
  336. \f2DBSETLPWD()\f1 sets the password that \*L will use when logging in.
  337. .Ih DBSETLPWD
  338. \f2DBSETLAPP()\f1 sets the name of the application, which will appear in the \*S's \f2sysprocess\f1 table.
  339. .Ih DBSETLAPP
  340. Routines are available for setting other aspects of the LOGINREC.
  341. However, in most environments these routines are optional; the LOGINREC contains default values 
  342. for each of the values they set.
  343. .Bl
  344. \f3dbopen()\f1.
  345. The \f2dbopen()\f1 routine opens a connection between the application and a \*S.
  346. .Ih dbopen
  347. It uses the LOGINREC supplied by \f2dblogin()\f1 to log into the server.
  348. It returns a DBPROCESS structure, which serves as the conduit for information
  349. between the application and the server.
  350. After this routine has been called, the application is connected with the \*S
  351. and can now send \*N commands to the \*S and process any results.
  352. .Bl
  353. \f3dbcmd()\f1.
  354. .Ih dbcmd
  355. .Ih "command buffer"
  356. .Ih "buffer, command"
  357. .Ih \*N commands, processing"
  358. This routine fills the command buffer with \*N commands, which 
  359. can then be sent to the \*S.
  360. Each succeeding call to \f2dbcmd()\f1 simply adds the supplied text
  361. to the end of any text already in the buffer.
  362. It is the programmer's responsibility to supply necessary blanks
  363. between words, such as the blank at the beginning of the text
  364. in the second \f2dbcmd()\f1 call in the example.
  365. Multiple commands can be included in the buffer.
  366. This example only shows how to send and process a single command, but
  367. \*L is designed to allow an application to send multiple commands to a \*S and process
  368. each command's set of results separately.
  369. .Bl
  370. \f3dbsqlexec()\f1.
  371. .Ih dbsqlexec
  372. This routine executes the command buffer; that is, it sends the contents of the buffer
  373. to the \*S, which parses and executes them.
  374. .Bl
  375. \f3dbresults()\f1.
  376. .Ih dbresults
  377. This routine gets the results of the current \*N command ready for processing.
  378. In this example, the buffer contains only a single command, so \f2dbresults()\f1 is
  379. called just once.
  380. If the buffer contained multiple commands, 
  381. the program would need to call \f2dbresults()\f1 once for each command in the buffer.
  382. .Bl
  383. \f3dbbind()\f1.
  384. .Ih dbbind
  385. \f2dbbind()\f1 binds result columns to program variables.
  386. In the example, the first call to \f2dbbind()\f1 binds the first result
  387. column to the variable ``name''.
  388. In other words, when the program reads a result
  389. row by calling \f2dbnextrow()\f1, 
  390. the contents of the first result column (``au_lname'') will get placed
  391. in the ``name'' variable.
  392. The second \f2dbbind()\f1 call 
  393. binds the second result column to the variable ``city''.
  394. .sp 0.5v
  395. The datatype of both bindings is ``STRINGBIND,'' one of several binding types
  396. available for character data.
  397. The binding type must correspond to the datatype of the specified program variable.
  398. In this example the ``name'' variable has a DBCHAR datatype, a
  399. \*L-defined datatype that accepts a STRINGBIND result.
  400. By means of the binding type parameter,
  401. \f2dbbind()\f1 supports a wide variety of type conversions, allowing 
  402. the datatype of the receiving variable to differ from
  403. the datatype of the result column.
  404. .Bl
  405. \f3dbnextrow()\f1.
  406. .Ih dbnextrow
  407. This routine reads a row and places the results in the program variables
  408. specified by the earlier \f2dbbind()\f1 calls.
  409. Each successive call to \f2dbnextrow()\f1 reads another result row, until the last row
  410. has been read and NO_MORE_ROWS is returned.
  411. Processing of the results must take place inside the \f2dbnextrow()\f1 loop, because
  412. each call to \f2dbnextrow()\f1 overwrites the previous values in the program variables.
  413. This example program merely prints each row's contents.
  414. .Bl
  415. \f3dbexit()\f1.
  416. .Ih dbexit
  417. This routine closes the \*S connection and de-allocates the DBPROCESS.
  418. .mc |
  419. It also cleans up any structures initialized by \f2dbinit()\f1.
  420. It must be the last \*L routine in the program.
  421. .Bz
  422. .mc
  423. Although \*L contains a great number of routines, much can be accomplished
  424. with just the few routines shown in this example.
  425. .H2 "\*L Datatypes"
  426. .Ih "datatypes, \*L"
  427. .Ih "\*L datatypes"
  428. \*L defines datatypes for \*S data.
  429. These datatypes begin with ``SYB'' (\f2e.g.,\f1 SYBINT4, SYBCHAR, SYBMONEY).
  430. Various routines require these \*S datatypes as parameters.
  431. \*L also provides typedefs for use in program variable declarations.
  432. These typedefs begin with the prefix ``DB'' (\f2e.g.,\f1 DBINT, DBCHAR, DBMONEY, etc.).
  433. By using them, you ensure that your program variables will be compatible with the 
  434. \*S datatypes.
  435. Section 2 includes a manual page, \f2types\f1, that lists the \*S datatypes and
  436. the \*L program variable types.
  437. .LP
  438. The \f2dbconvert()\f1 routine provides a way to convert data from one \*S datatype
  439. to another.
  440. .Ih dbconvert
  441. It supports conversion between most datatypes.
  442. Since the \*S datatypes correspond directly to the \*L datatypes,
  443. you can use \f2dbconvert()\f1 widely within your application.
  444. The routines that bind \*S result columns to program variables\(em\f2dbbind()\f1 and
  445. \f2dbaltbind()\f1\(emalso provide type conversion.
  446. .Ih dbbind
  447. .Ih dbaltbind
  448. .H1 "\*L Routines"
  449. .Ih "\*L routines, categories of"
  450. .Ih "Routines, categories of"
  451. The \*L routines and macros handle a large variety of tasks, which are divided
  452. in this section into a number of categories:
  453. .Bl
  454. Initialization
  455. .Bl
  456. Command Processing
  457. .Bl
  458. Results Processing
  459. .Bl
  460. Error and Message Handling
  461. .Bl
  462. Information Retrieval
  463. .Bl
  464. Browse Mode
  465. .Bl
  466. Text and Image Handling
  467. .Bl
  468. Datatype Conversion
  469. .Bl
  470. Process Control Flow
  471. .Bl
  472. Remote Procedure Call Processing
  473. .Bl
  474. Cleanup
  475. .Bl
  476. Miscellaneous
  477. .Bz
  478. The routines and macros are described in individual manual pages
  479. in Section 2.
  480. They all begin with the prefix ``db''.
  481. The routines are named with lowercase letters; the macros are capitalized.
  482. .LP
  483. In addition, \*L includes two special libraries:
  484. .Bl
  485. Bulk Copy
  486. .Bl
  487. Two-Phase Commit Service
  488. .Bz
  489. The routines in these libraries are described in manual pages in Section 3.
  490. The bulk copy routines begin with the prefix ``bcp''.
  491. The two-phase commit routines have no standard prefix.
  492. .H2 "Initialization"
  493. .Ih "initialization routines"
  494. .Ih "routines, initialization"
  495. These routines set up and define the connection between
  496. the application program and a \*S.
  497. They handle such tasks as allocating and defining
  498. a LOGINREC structure, opening a connection to a \*S, and allocating
  499. a DBPROCESS structure.
  500. Only a few of the routines are absolutely necessary in every
  501. \*L program; in particular, an application requires
  502. \f2dbinit()\f1, \f2dblogin()\f1 and \f2dbopen()\f1.
  503. The lists below specify the initialization routines in the approximate order
  504. in which a program is likely to call them.
  505. .mc |
  506. .H3 "Initializing \*L"
  507. .Ih "\*L, initializing"
  508. .Ih "initializing \*L"
  509. .LP
  510. .IP \f6dbinit\f1 18
  511. .Ih dbinit
  512. Initializes underlying structures used by \*L.
  513. .mc
  514. .H3 "Setting Up the LOGINREC"
  515. .Ih "LOGINREC, setting up" 
  516. .LP
  517. .IP \f6dblogin\f1 18
  518. .Ih dblogin
  519. Allocates a LOGINREC structure for subsequent use by \f2dbopen()\f1.
  520. .IP \f6DBSETLUSER\f1
  521. Sets the \*S username in the LOGINREC.
  522. .IP \f6DBSETLPWD\f1
  523. Sets the \*S password in the LOGINREC.
  524. .IP \f6DBSETLAPP\f1
  525. Sets the application name in the LOGINREC.
  526. .IP \f6DBSETLHOST\f1
  527. Sets the host name in the LOGINREC.
  528. .mc |
  529. .IP \f6dbloginfree\f1 
  530. .Ih dbloginfree
  531. Frees a LOGINREC structure.
  532. .mc
  533. .H3 "Establishing a \*S Connection"
  534. .Ih "\*S connection, establishing"
  535. .LP
  536. .IP \f6dbsetifile\f1 18
  537. Specifies the \f2interfaces\f1 file that \f2dbopen()\f1 
  538. will use to connect to a \*S.
  539. .mc |
  540. .IP \f6dbsetconnect\f1
  541. \f2OS/2, MS-DOS\(rg and Macintosh\(rg only\f1.
  542. Allocates and initializes a network connection structure
  543. that \f2dbopen()\f1 will use when opening a connection
  544. to a \*S.
  545. This routine can be used in place of the \f2interfaces\f1 file,
  546. which ordinarily determines which \*S
  547. a new DBPROCESS will connect to.
  548. .mc
  549. .IP \f6dbsetlogintime\f1
  550. Sets the number of seconds \*L will wait for a \*S
  551. to respond to a request by \f2dbopen()\f1 for a DBPROCESS
  552. connection.
  553. .IP \f6dbopen\f1
  554. .Ih dbopen
  555. Sets up communication with the network,
  556. logs into a \*S using the LOGINREC, initializes any 
  557. options specified in the LOGINREC, and allocates a DBPROCESS.
  558. An application can open multiple connections to a \*S, each
  559. connection having its own DBPROCESS.
  560. An application can also open multiple connections to multiple \*Ss.
  561. .H3 "Setting the Database"
  562. .Ih "database, setting"
  563. .LP
  564. .IP \f6dbuse\f1 18
  565. Sets the current database.
  566. This routine is equivalent to the \*N USE command and
  567. can be called repeatedly in an application.
  568. .H2 "Command Processing"
  569. .Ih "command processing routines"
  570. .Ih "routines, command processing"
  571. The application communicates with a \*S through \*N commands.
  572. It enters the commands into a command buffer, which the DBPROCESS points to.
  573. .Ih "command buffer"
  574. .Ih "buffer, command"
  575. The application can place multiple commands in the command buffer, and the
  576. set of commands in the buffer is known as the command batch.
  577. .Ih "command batch"
  578. .Ih "batch, command"
  579. The application then sends the command batch to a \*S, which executes the commands
  580. in the order entered in the buffer.
  581. .H3 "Building the Command Batch"
  582. .Ih "command batch, building"
  583. .LP
  584. These routines add commands to the buffer or clear the buffer.
  585. .IP \f6dbcmd\f1 18
  586. .Ih dbcmd
  587. Adds text to the command buffer.
  588. It may be called repeatedly to add multiple commands, or parts of commands.
  589. The text added with each successive call is concatenated to the previous
  590. text.
  591. .IP \f6dbfcmd\f1
  592. Adds text to the command buffer using \f2sprintf()\f1-type formatting.
  593. This routine is the same as \f2dbcmd()\f1, except that it allows arguments
  594. to be substituted into the text.
  595. .IP \f6dbfreebuf\f1
  596. Clears the command buffer.
  597. The command buffer is automatically cleared 
  598. before a batch of commands is entered.
  599. To clear it at other times or when the DBNOAUTOFREE option has been set, 
  600. use \f2dbfreebuf()\f1.
  601. .H3 "Accessing the Command Batch"
  602. .Ih "command batch, accessing"
  603. .LP
  604. These routines may be used to examine and copy parts of the command buffer.
  605. .IP \f6dbgetchar\f1 18
  606. Returns a pointer to a particular character in the command buffer.
  607. .IP \f6dbstrlen\f1
  608. Returns the length of the command buffer.
  609. .IP \f6dbstrcpy\f1
  610. Copies a portion of the command buffer to a program variable.
  611. This routine is particularly valuable for debugging, because
  612. it can tell you exactly what was sent to the \*S.
  613. .Ih "debugging"
  614. .H3 "Executing the Command Batch"
  615. .Ih "command batch, executing"
  616. .LP
  617. Once \*N commands have been entered in the
  618. buffer, they can be sent to a \*S for execution.
  619. .IP \f6dbsqlexec\f1 18
  620. .Ih dbsqlexec
  621. Sends the contents of the command buffer to a \*S for execution.
  622. Once \f2dbsqlexec()\f1 has returned SUCCEED, \f2dbresults()\f1 must
  623. be called to process the results.
  624. Calling \f2dbsqlexec()\f1 is equivalent to calling \f2dbsqlsend()\f1
  625. followed by \f2dbsqlok()\f1.
  626. .IP \f6dbsqlsend\f1
  627. Sends the contents of the command buffer to a \*S for execution.
  628. Unlike \f2dbsqlexec()\f1, this routine does not wait for a response
  629. from the \*S.
  630. When \f2dbsqlsend()\f1 has returned SUCCEED, \f2dbsqlok()\f1 must
  631. be called to verify the correctness of the command batch.
  632. .IP \f6dbsqlok\f1
  633. Waits for results from the \*S and verifies the
  634. correctness of the instructions the server is responding to.
  635. This routine is used in conjunction with \f2dbsqlsend()\f1, \f2dbrpcsend()\f1,
  636. and \f2dbmoretext()\f1.
  637. After a successful \f2dbsqlok()\f1 call, the application must call \f2dbresults()\f1 
  638. to process the results.
  639. .H3 "Setting and Clearing Command Options"
  640. .Ih "command options"
  641. .Ih "options, command"
  642. .LP
  643. The application can set a
  644. number of \*S and \*L command options.
  645. Among them are DBPARSEONLY, which causes the \*S to parse but not
  646. execute the command batch, 
  647. and DBBUFFER, which provides buffering of result rows.
  648. For a list of all available options and their significance, see
  649. the \f2options\f1 manual page at the end of Section 2.
  650. .IP \f6dbsetopt\f1 18
  651. Sets an option.
  652. .IP \f6dbclropt\f1
  653. Clears an option.
  654. .IP \f6dbisopt\f1
  655. Determines whether a particular option is set.
  656. .H2 "Results Processing"
  657. .Ih "results processing routines"
  658. .Ih "routines, results processing"
  659. Once a command batch has been executed in the \*S, 
  660. indicated by \f2dbsqlexec()\f1 or \f2dbsqlok()\f1
  661. returning SUCCEED, the application must process any results.
  662. Result rows are returned by
  663. SELECT commands and EXECUTEs on stored procedures
  664. that contain SELECT commands.
  665. .LP
  666. There are two types of result rows:
  667. regular rows and compute rows.
  668. .Ih "rows, types of"
  669. .Ih "result rows, types of"
  670. .Ih "regular rows"
  671. .Ih "rows, regular"
  672. .Ih "compute rows"
  673. .Ih "rows, compute"
  674. Regular rows are generated from columns in a
  675. SELECT command's \f2select-list\f1; compute
  676. rows are generated from columns in a SELECT
  677. command's COMPUTE clause.
  678. Since these two types of rows contain very different data,
  679. the application must process them separately.
  680. .LP
  681. The results for each command in a batch
  682. are returned to the application separately.
  683. Within each command's set of results,
  684. the result rows are processed one at a time.
  685. .H3 "Setting Up the Results"
  686. .Ih "results, setting up"
  687. .LP
  688. .IP \f6dbresults\f1 18
  689. Sets up the results of the next command in the batch.
  690. This routine must be called once for each command in the
  691. batch, whether or not the command returns rows.
  692. .Ih dbresults
  693. .sp 0.5v
  694. \f2dbresults()\f1 must be called after \f2dbsqlexec()\f1
  695. or \f2dbsqlok()\f1 has returned SUCCEED, but before
  696. calls to \f2dbbind()\f1 or \f2dbnextrow()\f1.
  697. .H3 "Getting Result Data"
  698. .Ih "result data, getting"
  699. .LP
  700. The simplest way to get result data is to bind result
  701. columns to program variables, using \f2dbbind()\f1 and
  702. \f2dbaltbind()\f1.
  703. .Ih dbbind
  704. .Ih dbaltbind
  705. .Ih "result data, binding to variables"
  706. Then, when the application calls \f2dbnextrow()\f1 to read a result row
  707. (see the next section),
  708. \*L will automatically place copies of the columns' data 
  709. into the program variables to which they are bound.
  710. The application must call \f2dbbind()\f1 and \f2dbaltbind()\f1 after
  711. a \f2dbresults()\f1 call but before the first call to \f2dbnextrow()\f1.
  712. .LP
  713. You can also access a result column's data directly with \f2dbdata()\f1
  714. and \f2dbadata()\f1, which return pointers to the data.
  715. \f2dbdata()\f1 and \f2dbadata()\f1 have the advantage of providing
  716. access to the actual data, not a copy of the data.
  717. .Ih dbdata
  718. .Ih dbadata
  719. .Ih "result data, accessing directly"
  720. These routines are frequently used in conjunction with
  721. \f2dbdatlen()\f1 and \f2dbadlen()\f1, which return the length
  722. of the data and are described later, in the section ``Information Retrieval.''
  723. When you are accessing data directly with these routines, you do not
  724. perform any preliminary binding of result columns to program variables.
  725. Simply call \f2dbdata()\f1 or \f2dbadata()\f1 after a \f2dbnextrow()\f1 call.
  726. .IP \f6dbbind\f1 18
  727. Binds a regular row result column to a program variable.
  728. .IP \f6dbaltbind\f1
  729. Binds a compute row result column to a program variable.
  730. .IP \f6dbdata\f1
  731. Returns a pointer to the data for a regular row result column.
  732. .IP \f6dbadata\f1
  733. Returns a pointer to the data for a compute row result column.
  734. .H3 "Reading Result Rows"
  735. .Ih "result rows, reading"
  736. .Ih "row data, reading"
  737. .LP
  738. Once \f2dbresults()\f1 has returned SUCCEED and any binding
  739. of columns to variables has been specified, the application is ready
  740. to process the results.
  741. The first step is to make the result rows available to the application.
  742. The \f2dbnextrow()\f1 routine accomplishes this.
  743. .Ih dbnextrow
  744. Each call to \f2dbnextrow()\f1 reads the next row returned from the \*S.
  745. The row is read directly from the network.
  746. .LP
  747. Once a row has been read in by \f2dbnextrow()\f1, the application can
  748. perform any processing desired on the data in the row.
  749. If the result columns have been bound to program variables,
  750. the data in the row will have been automatically copied into the variables.
  751. Alternatively, the data is accessible through \f2dbdata()\f1 or \f2dbadata()\f1.
  752. .LP
  753. Rows read in by \f2dbnextrow()\f1 may be automatically saved in a row buffer, if desired.
  754. The application accomplishes this
  755. by setting the DBBUFFER option with the \f2dbsetopt()\f1 routine.
  756. Row buffering is useful for applications that need to process result rows
  757. in a non-sequential manner.
  758. .Ih "buffer, row"
  759. .Ih "row buffer"
  760. .Ih "DBBUFFER option"
  761. Without row buffering, the application must process each row as it is read in
  762. by \f2dbnextrow()\f1, because the next call to \f2dbnextrow()\f1 will
  763. overwrite the row.
  764. If the application has enabled row buffering,
  765. the rows are added to a row buffer as they are read in by \f2dbnextrow()\f1.
  766. The application can then use the \f2dbgetrow()\f1 routine
  767. to skip around in the buffer and return to previously read rows.
  768. Since row buffering carries a memory and performance penalty, use it 
  769. with discretion.
  770. Note that row buffering has nothing to do with network buffering 
  771. and is a completely independent issue.
  772. .LP
  773. Routines are also available to print result rows in a default format.
  774. Because the format is predetermined, these routines are of limited usefulness
  775. and are appropriate primarily for debugging. 
  776. .Ih debugging
  777. .LP
  778. Note that \*L processes results one command at a time.
  779. When the application has read all the results for one command,
  780. it must call \f2dbresults()\f1 again to set up the results for the next
  781. command in the command buffer.
  782. .IP \f6dbnextrow\f1 18
  783. Reads in the next row.
  784. The return value from \f2dbnextrow()\f1 tells the application whether the
  785. row is a regular row or a compute row, whether the row buffer is full, and
  786. whether the last result row has been read.
  787. .IP \f6dbgetrow\f1
  788. Reads the specified row in the row buffer.
  789. This routine provides the application with access to buffered rows that have
  790. been previously read by \f2dbnextrow()\f1.
  791. .IP \f6dbclrbuf\f1
  792. Drops rows from the row buffer.
  793. .IP \f6dbprrow\f1
  794. Prints all the result rows in a default format.
  795. When this routine is used, the program does not need to bind results or 
  796. call \f2dbnextrow()\f1.
  797. .IP \f6dbprhead\f1
  798. Prints default column headings for result rows.
  799. This routine is used in conjunction with \f2dbprrow()\f1.
  800. .H3 "Canceling Results"
  801. .Ih "results, canceling"
  802. .LP
  803. .IP \f6dbcancel\f1 18
  804. Cancels results from the current command batch.
  805. This routine cancels \f2all\f1 the commands in the current batch.
  806. .IP \f6dbcanquery\f1
  807. Cancels any rows pending from the most recently executed query.
  808. .mc |
  809. .H3 "Handling Stored Procedure Results"
  810. .Ih "stored procedure results, handling"
  811. .Ih "procedure, stored"
  812. .LP
  813. A call to a stored procedure is made through either 
  814. a remote procedure call, discussed in a later section, or
  815. a \*N EXECUTE command.
  816. The call can generate several types of results.
  817. First of all, a stored procedure that contains SELECT statements
  818. will return result rows in the usual fashion.
  819. Each successive call
  820. to \f2dbresults()\f1 will access the set of rows from the next
  821. SELECT statement in the stored procedure.
  822. These rows can be processed, as usual, with \f2dbnextrow()\f1.
  823. .LP
  824. Second, stored procedures can contain ``return parameters.''
  825. .Ih "stored procedure, return parameters"
  826. .Ih "return parameters from stored procedures"
  827. Return parameters provide stored procedures with a ``call-by-reference'' capability.
  828. Any change that a stored procedure makes internally
  829. to the value of a return parameter is available
  830. to the calling program once it has processed 
  831. all of the stored procedure's result rows, if any, by calling
  832. \f2dbresults()\f1 and \f2dbnextrow()\f1.
  833. A number of routines, described below, process return parameter values.
  834. .LP
  835. Third, stored procedures can return a status number, which the program can access through
  836. routines described below.
  837. .Ih "stored procedure, status number returned by"
  838. .Ih "return status, stored procedure"
  839. .Ih "status value, stored procedure"
  840. .LP
  841. .IP \f6dbretdata\f1 18
  842. Returns a pointer to a return parameter value.
  843. .IP \f6dbretlen\f1
  844. Returns the length of a return parameter value.
  845. .IP \f6dbrettype\f1
  846. Returns the datatype of a return parameter value.
  847. .IP \f6dbretname\f1
  848. Returns the name of the return parameter associated with a particular value.
  849. .IP \f6dbnumrets\f1
  850. Returns the number of return parameter values generated by a stored procedure.
  851. .IP \f6dbretstatus\f1
  852. Returns the stored procedure's status number.
  853. .IP \f6dbhasretstat\f1
  854. Indicates whether the current command or remote procedure call
  855. generated a stored procedure status number.
  856. .mc
  857. .H3 "Miscellaneous Results Processing"
  858. .LP
  859. .IP \f6dbsettime\f1 18
  860. Sets the number of seconds that \*L will wait for a \*S response.
  861. .IP \f6DBGETTIME\f1 
  862. Gets the number of seconds that \*L will wait for a \*S response.
  863. .H2 "Error and Message Handling"
  864. .Ih "error handling routines"
  865. .Ih "routines, error handling"
  866. .Ih "message handling routines"
  867. .Ih "routines, message handling"
  868. .Ih "errors, \*L"
  869. .Ih "errors, \*S"
  870. .Ih "messages, \*S"
  871. .Ih "\*L errors"
  872. .Ih "\*S errors"
  873. .Ih "\*S messages"
  874. \*L applications must deal with two types of errors and messages:
  875. those from the \*S (known as ``messages'') and those generated
  876. by \*L routines (known as ``errors'').
  877. The \*S can return both informational and error messages to the application.
  878. In addition, \*L has its own set of possible warnings and errors.
  879. .LP
  880. See the \f2\*S Reference Supplement\f1 for a list of \*S messages.
  881. For a list of \*L errors, see the \f2errors\f1 manual page at the end of Section 2.
  882. .LP
  883. \*L provides an easy way to centralize error and message
  884. handling.
  885. Using \f2dbmsghandle()\f1 and \f2dberrhandle()\f1, you can
  886. install your own message and error handling routines.
  887. .Ih dbmsghandle
  888. .Ih dberrhandle
  889. When a message or error then occurs, \*L will automatically call the
  890. appropriate user-supplied function, providing information to that
  891. function on the nature of the message or error.
  892. The error and message handling logic can thus be relegated to two
  893. functions in your application.
  894. .IP \f6dbmsghandle\f1 18
  895. Installs a user function to handle \*S informational and error messages.
  896. .IP \f6dberrhandle\f1 18
  897. Installs a user function to handle \*L error messages.
  898. .IP \f6DBDEAD\f1
  899. .Ih "DBPROCESS, dead"
  900. .Ih "DBDEAD"
  901. Determines whether a particular DBPROCESS is dead.
  902. When a DBPROCESS is dead, the current \*L routine
  903. fails, causing the error handler to be called.
  904. .H2 "Information Retrieval"
  905. .Ih "information retrieval routines"
  906. .Ih "routines, information retrieval"
  907. Information covering several areas,
  908. including regular result columns,
  909. compute result columns, row buffers, and the command state,
  910. can be retrieved from the DBPROCESS structure.
  911. As mentioned earlier, regular result columns correspond to 
  912. columns in the SELECT command's \f2select-list\f1 and
  913. compute result columns correspond to columns in the 
  914. SELECT command's optional COMPUTE clause.
  915. .H3 "Regular Result Column Information"
  916. .LP
  917. These routines can be called after \f2dbsqlexec()\f1 returns
  918. SUCCEED.
  919. .IP \f6dbnumcols\f1 18
  920. Determines the number of columns in the current set of results.
  921. .IP \f6dbcolname\f1
  922. Returns the name of a regular result column.
  923. .IP \f6dbcollen\f1
  924. Returns the maximum length for a regular column's data.
  925. .IP \f6dbcoltype\f1
  926. Returns the \*S datatype for a regular result column.
  927. .IP \f6dbdatlen\f1
  928. Returns the actual length of a regular column's data.
  929. This routine is often used in conjunction with \f2dbdata()\f1.
  930. The value returned by \f2dbdatlen()\f1 is different for each regular row read by
  931. \f2dbnextrow()\f1.
  932. .mc |
  933. .IP \f6dbvarylen\f1
  934. Indicates whether the column's data can vary in length.
  935. .mc
  936. .H3 "Compute Result Column Information"
  937. .LP
  938. These routines can be called after \f2dbsqlexec()\f1 returns
  939. SUCCEED.
  940. .IP \f6dbnumcompute\f1 18
  941. Returns the number of COMPUTE clauses in the current set of results.
  942. .IP \f6dbnumalts\f1
  943. Returns the number of columns in a compute row.
  944. .IP \f6dbbylist\f1
  945. Returns the bylist for a compute row.
  946. .IP \f6dbaltop\f1
  947. Returns the type of aggregate operator for a compute column.
  948. .IP \f6dbalttype\f1
  949. Returns the datatype for a compute column.
  950. .IP \f6dbaltlen\f1
  951. Returns the maximum length for a compute column's data.
  952. .IP \f6dbaltcolid\f1
  953. Returns the column id for a compute column.
  954. .IP \f6dbadlen\f1
  955. Returns the actual length of a compute column's data.
  956. This routine is often used in conjunction with \f2dbadata()\f1.
  957. The value returned by \f2dbadlen()\f1 is different for each compute row read by
  958. \f2dbnextrow()\f1.
  959. .H3 "Row Buffer Information"
  960. .LP
  961. These macros return information that can be useful
  962. when manipulating result rows in buffers.
  963. .IP \f6DBFIRSTROW\f1 18
  964. Returns the number of the first row in the buffer.
  965. .IP \f6DBLASTROW\f1
  966. Returns the number of the last row in the buffer.
  967. .H3 "Command State Information"
  968. .LP
  969. These routines return information about the current state of the command batch.
  970. Several of them return information about the ``current'' command\(emthat is,
  971. the command currently being processed by \f2dbresults()\f1.
  972. .IP \f6DBCURCMD\f1 18
  973. Returns the number of the current command in a batch.
  974. .IP \f6dbgetoff\f1
  975. Checks for the existence of specified \*N constructs in the 
  976. command buffer.
  977. This routine is used in conjunction with the DBOFFSET option.
  978. .Ih "DBOFFSET option"
  979. .IP \f6DBMORECMDS\f1
  980. Indicates whether there are more commands in the batch.
  981. .IP \f6DBCMDROW\f1
  982. Indicates whether the current command is one that can return rows
  983. (\f2i.e.,\f1 a SELECT or a stored procedure containing a SELECT).
  984. .IP \f6DBROWS\f1
  985. Indicates whether the current command actually did return rows.
  986. .IP \f6DBCOUNT\f1
  987. Returns the number of rows affected by a command.
  988. .IP \f6DBNUMORDERS\f1
  989. Returns the number of columns specified in a SELECT command's ORDER BY clause.
  990. .IP \f6dbordercol\f1
  991. Returns the id of a column appearing in a SELECT command's ORDER BY clause.
  992. .H3 "Miscellaneous Information"
  993. .LP
  994. .IP \f6DBCURROW\f1 18
  995. Returns the number of the row currently being read.
  996. .IP \f6DBROWTYPE\f1
  997. Indicates whether the current result row is a regular row or a compute row.
  998. .IP \f6DBISAVAIL\f1
  999. Indicates whether a DBPROCESS is available for general use.
  1000. .IP \f6dbname\f1
  1001. Returns the name of the current database.
  1002. .IP \f6dbchange\f1
  1003. Indicates whether a command batch has changed the current database.
  1004. .IP \f6dbgetmaxprocs\f1
  1005. Indicates the current maximum number of simultaneously open DBPROCESSes.
  1006. .mc |
  1007. .H2 "Browse Mode"
  1008. .Ih "browse mode routines"
  1009. .Ih "routines, browse mode"
  1010. Browse mode provides a means for browsing through database rows and updating
  1011. their values a row at a time.
  1012. From the standpoint of the program,
  1013. the process involves several steps, because 
  1014. each row must be transferred from the database into program
  1015. variables before it can be browsed and updated.
  1016. .LP
  1017. Since a row being browsed is not the actual row residing in the database,
  1018. but is instead a copy residing in program variables, the program
  1019. must be able to ensure that changes to the variables' values can be reliably
  1020. used to update the original database row.
  1021. .Ih "updating the database"
  1022. .Ih "database updates"
  1023. .Ih "multi-user updates"
  1024. .Ih "updates, multi-user"
  1025. In particular, in multi-user situations, the program needs to ensure that
  1026. updates made to the database by one user do not unwittingly overwrite
  1027. updates recently made by another user.
  1028. This can be a problem because the application typically selects a number of
  1029. rows from the database at one time, but the application's users 
  1030. browse and update the database one row at a time.
  1031. A \f2timestamp\f1 column in browsable database tables provides the information
  1032. necessary to regulate this type of multi-user updating.
  1033. .Ih "timestamp, browse mode"
  1034. .LP
  1035. Browse mode routines also allow an application to handle ad hoc queries.
  1036. .Ih "ad hoc queries, processing"
  1037. .Ih "queries, ad hoc"
  1038. Several of them return information that an application can use to
  1039. examine the structure of 
  1040. a complicated ad hoc query in order to update the underlying database tables.
  1041. .LP
  1042. Conceptually, browse mode involves three steps:
  1043. .Ih "browse mode, steps"
  1044. .Bl 1.
  1045. Select result rows containing columns derived from one or more database tables.
  1046. .Bl 2.
  1047. Where appropriate,
  1048. change values in columns of the result rows (\f2not\f1 the actual database rows), 
  1049. one row at a time.
  1050. .Bl 3.
  1051. Update the original database tables, one row at a time, 
  1052. using the new values in the result rows.
  1053. .Bz
  1054. .LP
  1055. These steps are implemented in a program as follows:
  1056. .Bl 1.
  1057. Execute a SELECT command, generating result rows containing result columns.
  1058. The SELECT command must include the FOR BROWSE option.
  1059. .Bl 2.
  1060. Copy the result column values into program variables, one row at a time.
  1061. .Bl 3.
  1062. If appropriate,
  1063. change the variables' values (possibly in response to user input).
  1064. .Bl 4.
  1065. If appropriate, execute an UPDATE command that updates
  1066. the database row corresponding to the current result row.
  1067. To handle multi-user updates,
  1068. the WHERE clause of the UPDATE command must reference the timestamp column.
  1069. Such a WHERE clause can be obtained via the \f2dbqual()\f1 function.
  1070. .Ih dbqual
  1071. .Bl 5.
  1072. Repeat the second, third, and fourth steps for each result row.
  1073. .Bz
  1074. .LP
  1075. To use browse mode, the following conditions must be true:
  1076. .Bl
  1077. The SELECT command must end with the key words FOR BROWSE.
  1078. .Bl
  1079. The table(s) to be updated must be ``browsable'' (\f2i.e.,\f1 each must have
  1080. a unique index and a timestamp column).
  1081. .Ih "table, browsable"
  1082. .Ih "browsable table"
  1083. .Bl
  1084. The result columns to be used in the updates must be ``updatable''\(emthey 
  1085. must be derived from browsable tables 
  1086. and cannot be the result of SQL expressions, such as ``max(colname)''.
  1087. .Ih "updatable result columns"
  1088. .Ih "columns, updatable"
  1089. In other words, there must be a valid correspondence between the result column and 
  1090. the database column to be updated.
  1091. .Bz
  1092. In addition, browse mode usually requires two DBPROCESSes\(emone for selecting 
  1093. the data and another for performing updates based on the selected data.
  1094. .LP
  1095. For examples of browse mode programming, see the \f2\*L Reference Supplement\f1.
  1096. .LP
  1097. The following constitute the browse mode routines:
  1098. .IP \f6dbqual\f1 18
  1099. Returns a pointer to a WHERE clause suitable for use in updating the current
  1100. row in a browsable table.
  1101. .IP \f6dbfreequal\f1
  1102. Frees the memory allocated by \f2dbqual()\f1.
  1103. .IP \f6dbtsnewval\f1
  1104. Returns the new value of the timestamp column after a browse-mode update.
  1105. .IP \f6dbtsnewlen\f1
  1106. Returns the length of the new value of the timestamp column after a browse-mode update.
  1107. .IP \f6dbtsput\f1
  1108. Puts the new value of the timestamp column into the given table's current row
  1109. in the DBPROCESS.
  1110. .IP \f6dbcolbrowse\f1 
  1111. Indicates whether the source of a result column is updatable via browse mode.
  1112. .IP \f6dbcolsource\f1
  1113. Returns a pointer to the name of the database column from which the specified
  1114. result column was derived.
  1115. .IP \f6dbtabbrowse\f1
  1116. Indicates whether a particular table is updatable via browse mode.
  1117. .IP \f6dbtabcount\f1
  1118. Returns the number of tables involved in the current SELECT command.
  1119. .IP \f6dbtabname\f1
  1120. Returns the name of a table based on its number.
  1121. .IP \f6dbtabsource\f1
  1122. Returns the name and number of the table from which a particular result column
  1123. was derived.
  1124. .H2 "Text and Image Handling"
  1125. .Ih "text handling routines"
  1126. .Ih "image handling routines"
  1127. .Ih "routines, text and image handling"
  1128. Since text and image values can be quite large, several routines are available to facilitate
  1129. the process of updating text and image columns in database tables:
  1130. .IP \f6dbwritetext\f1 18
  1131. Sends a text or image value to the \*S.
  1132. .IP \f6dbmoretext\f1
  1133. Sends part of a text or image value to the \*S.
  1134. .IP \f6dbtxptr\f1
  1135. Returns the text pointer for a column in the current results row.
  1136. .Ih "pointer, text"
  1137. .Ih "text pointer"
  1138. .IP \f6dbtxtimestamp\f1
  1139. .Ih "timestamp, text"
  1140. .Ih "text timestamp"
  1141. Returns the value of the text timestamp for a column in the current results row.
  1142. .IP \f6dbtxtsnewval\f1
  1143. Returns the new value of a text timestamp after a call to \f2dbwritetext()\f1.
  1144. .IP \f6dbtxtsput\f1
  1145. Puts the new value of a text timestamp into the specified column of the current
  1146. row in the DBPROCESS.
  1147. .mc
  1148. .H2 "Datatype Conversion"
  1149. .Ih "datatype conversion routines"
  1150. .Ih "conversion routines"
  1151. .Ih "routines, datatype conversion"
  1152. \*L supports conversions between most \*S datatypes with the \f2dbconvert()\f1 routine.
  1153. For information on \*S datatypes, see the \f2types\f1 manual page at the end of Section 2.
  1154. .LP
  1155. The \f2dbbind()\f1 and \f2dbaltbind()\f1 routines, which bind result columns to program
  1156. variables, can also be used to perform type conversion.
  1157. Those routines each contain a parameter that specifies the datatype of the receiving program
  1158. variable. 
  1159. If the data being returned from the \*S is of a different datatype,
  1160. \*L will usually convert it automatically to the type specified by the parameter.
  1161. .IP \f6dbconvert\f1 18
  1162. .Ih dbconvert
  1163. Converts data from one \*S datatype to another.
  1164. .IP \f6dbwillconvert\f1
  1165. Indicates whether a specified datatype conversion is supported.
  1166. .H2 "Process Control Flow"
  1167. .Ih "process control flow routines"
  1168. .Ih "control flow routines"
  1169. .Ih "routines, process control flow"
  1170. These routines allow the application to schedule its actions around its interaction
  1171. with the \*S.
  1172. .IP \f6dbsetbusy\f1 18
  1173. Calls a user-supplied function when \*L is reading or waiting to read 
  1174. results from the \*S.
  1175. .IP \f6dbsetidle\f1
  1176. Calls a user-supplied function when \*L is finished reading from the \*S.
  1177. .IP \f6dbsetinterrupt\f1
  1178. Calls user-supplied functions to handle interrupts while waiting on a read from the \*S.
  1179. .IP \f6DBIORDESC\f1
  1180. \f2UNIX\(rg only\f1.
  1181. Provides access to the UNIX file descriptor used to read data coming from the \*S,
  1182. allowing the application to respond to multiple input data streams.
  1183. .IP \f6DBIOWDESC\f1
  1184. \f2UNIX only\f1.
  1185. Provides access to the UNIX file descriptor used to write data to the \*S,
  1186. allowing the application to effectively utilize multiple input 
  1187. and output data streams.
  1188. .IP \f6DBRBUF\f1
  1189. \f2UNIX only\f1.
  1190. Determines whether the \*L network buffer contains any unread bytes.
  1191. .mc |
  1192. .IP \f6dbcancel_a\f1
  1193. .Ss \f2VMS\fP TM
  1194. \f2only\f1.
  1195. The asynchronous version of \f2dbcancel()\f1.
  1196. .Ih "asynchronous routines (VMS)"
  1197. .IP \f6dbnextrow_a\f1
  1198. \f2VMS only\f1.
  1199. The asynchronous version of \f2dbnextrow()\f1.
  1200. .IP \f6dbopen_a\f1
  1201. \f2VMS only\f1.
  1202. The asynchronous version of \f2dbopen()\f1.
  1203. .IP \f6dbresults_a\f1
  1204. \f2VMS only\f1.
  1205. The asynchronous version of \f2dbresults()\f1.
  1206. .IP \f6dbsqlexec_a\f1
  1207. \f2VMS only\f1.
  1208. The asynchronous version of \f2dbsqlexec()\f1.
  1209. .mc
  1210. .mc |
  1211. .H2 "Remote Procedure Call Processing"
  1212. .Ih "remote procedure calls, processing"
  1213. .Ih "stored procedures, calling remotely"
  1214. .Ih "calls, remote procedure"
  1215. A remote procedure call is simply a call to a stored
  1216. procedure residing on a remote server.
  1217. Either an application or another server makes the call.
  1218. A remote procedure call made by an application has
  1219. the same effect as an EXECUTE command\(emit executes the stored procedure,
  1220. generating results accessible through \f2dbresults()\f1.
  1221. However, a remote procedure call is often more efficient than an EXECUTE command.
  1222. .LP
  1223. A server can make a remote procedure call to another server.
  1224. This occurs when a stored procedure being executed on one server 
  1225. contains an EXECUTE command for a stored procedure on another server. 
  1226. The EXECUTE command causes the first server to log into the second
  1227. server and perform a remote procedure call on the procedure.
  1228. This happens without any intervention from the application,
  1229. although the application can specify the remote password which the
  1230. first server uses to log in.
  1231. .IP \f6dbrpcinit\f1 18
  1232. Initializes a remote procedure call to a stored procedure.
  1233. .IP \f6dbrpcparam\f1
  1234. Adds a parameter to a remote procedure call.
  1235. .IP \f6dbrpcsend\f1
  1236. Signals the end of a remote procedure call, causing the server
  1237. to begin executing the specified procedure.
  1238. .IP \f6dbrpwset\f1
  1239. Adds a remote password to a LOGINREC structure.
  1240. The server will use this password when it 
  1241. performs a remote procedure call on another server.
  1242. .IP \f6dbrpwclr\f1
  1243. Clears all remote passwords from a LOGINREC structure.
  1244. .mc
  1245. .H2 "Cleanup"
  1246. .Ih "cleanup routines"
  1247. .Ih "routines, cleanup"
  1248. These routines sever the connection between the application and the \*S.
  1249. .IP \f6dbexit\f1 18
  1250. .Ih dbexit
  1251. Closes and de-allocates all DBPROCESS structures.
  1252. .mc |
  1253. This routine also cleans up any structures initialized by \f2dbinit()\f1.
  1254. .mc
  1255. .IP \f6dbclose\f1
  1256. .Ih dbclose
  1257. Closes and de-allocates a single DBPROCESS structure.
  1258. .H2 "Miscellaneous Routines"
  1259. .Ih "miscellaneous routines"
  1260. .Ih "routines, miscellaneous"
  1261. .IP \f6dbsetavail\f1 18
  1262. Marks a DBPROCESS as being available for general use.
  1263. .IP \f6dbsetmaxprocs\f1
  1264. Sets the maximum number of simultaneously open DBPROCESSes.
  1265. .mc |
  1266. .IP \f6dbsetuserdata\f1
  1267. Uses a DBPROCESS structure to save a pointer to user-allocated
  1268. data.
  1269. This routine, along with \f2dbgetuserdata()\f1, allows the application
  1270. to associate user data with a particular DBPROCESS.
  1271. One important use for these routines is to transfer information
  1272. between a \*S message handler and the program code that triggered it.
  1273. .IP \f6dbgetuserdata\f1
  1274. Returns a pointer to user-allocated data from a DBPROCESS structure.
  1275. .mc
  1276. .IP \f6dbsetnull\f1
  1277. Defines substitution values to be used when binding null values.
  1278. .IP \f6dbprtype\f1
  1279. Converts a \*S type token into a readable string.
  1280. Tokens are returned by various routines such as \f2dbcoltype()\f1 and \f2dbaltop()\f1.
  1281. .IP \f6dbreadpage\f1
  1282. Reads in a page of binary data from the \*S.
  1283. .IP \f6dbwritepage\f1
  1284. Writes a page of binary data to the \*S.
  1285. .H2 "Bulk Copy Special Library"
  1286. .Ih "bulk copy special library"
  1287. .Ih "bcp routines"
  1288. .Ih "library, bulk copy"
  1289. The routines in this library allow an application to bulk
  1290. copy data in and out of the \*S.
  1291. They provide a facility for high-speed loading of data
  1292. into the \*S from either files or program variables.
  1293. .Ih "data, high-speed loading of"
  1294. They also allow you to copy data out
  1295. of the \*S into files, using a pre-defined format.
  1296. The bulk copy routines are similar in function
  1297. to the \f2bcp\f1 utility
  1298. program, described in the \f2Commands Reference\f1.
  1299. .Ih "bcp utility"
  1300. .mc |
  1301. .IP \f6BCP_SETL\f1 18
  1302. Sets the LOGINREC for bulk copy operations.
  1303. .IP \f6bcp_init\f1
  1304. Initializes bulk copy.
  1305. .IP \f6bcp_bind\f1
  1306. Binds data from a program variable to a \*S table.
  1307. .IP \f6bcp_sendrow\f1
  1308. Sends a row of data from program variables to the \*S.
  1309. .IP \f6bcp_moretext\f1
  1310. Sends part of a text or image value to the \*S.
  1311. .IP \f6bcp_collen\f1
  1312. Sets the program variable data length for the current copy IN.
  1313. .IP \f6bcp_colptr\f1
  1314. Sets the program variable data address for the current copy IN.
  1315. .IP \f6bcp_batch\f1
  1316. Saves any preceding rows in the \*S.
  1317. .IP \f6bcp_done\f1
  1318. Ends a bulk copy from program variables into the \*S.
  1319. .IP \f6bcp_control\f1
  1320. Changes various control parameter default settings.
  1321. .IP \f6bcp_columns\f1
  1322. Sets the total number of columns found in the host file.
  1323. .IP \f6bcp_colfmt\f1
  1324. Specifies the format of a host file for bulk copy purposes.
  1325. .IP \f6bcp_exec\f1
  1326. Executes a bulk copy of data between a database table and a host file.
  1327. .mc
  1328. .H2 "Two-Phase Commit Service Special Library"
  1329. .Ih "two-phase commit service special library"
  1330. .Ih "library, two-phase commit service"
  1331. The routines in this library allow an application to 
  1332. coordinate updates among two or more SQL Servers.
  1333. See the introduction to this library in Section 3 for detailed information
  1334. on the two-phase commit service.
  1335. .IP \f6open_commit\f1 18
  1336. Establishes a connection with the commit service.
  1337. .IP \f6start_xact\f1
  1338. Starts a distributed transaction using the commit service.
  1339. .IP \f6build_xact_string\f1
  1340. Builds a name for a distributed transaction.
  1341. .IP \f6commit_xact\f1
  1342. Marks a distributed transaction as being committed.
  1343. .IP \f6abort_xact\f1 
  1344. Marks a distributed transaction as being aborted.
  1345. .IP \f6stat_xact\f1
  1346. Returns the current status of a distributed transaction.
  1347. .IP \f6remove_xact\f1
  1348. Decrements the count of sites still active in the distributed transaction.
  1349. .IP \f6scan_xact\f1
  1350. Prints commit service record for distributed transactions.
  1351. .IP \f6close_commit\f1
  1352. Ends a connection with the commit service.
  1353. .H1 "What's in this Book"
  1354. .Ih "\*L Reference Manual, contents of"
  1355. Section 2 contains separate manual pages for each of the \*L routines.
  1356. Each manual page includes:
  1357. .Bl
  1358. A summary of the routine's function.
  1359. .Bl
  1360. The syntax of the routine's calling interface.
  1361. .Bl
  1362. A thorough description of the routine, including issues of syntax, usage, and
  1363. run-time behavior.
  1364. .Bl
  1365. Descriptions of each of the routine's parameters.
  1366. .Bl
  1367. Descriptions of the routine's return values, if any.
  1368. .Bl
  1369. A list of related routines.
  1370. .Bz
  1371. .LP
  1372. Section 3 contains manual pages for the special library routines.
  1373. The Bulk Copy library is presented first, followed by the Two-Phase Commit Service library.
  1374. Section 3 also provides an introduction to
  1375. the two-phase commit service.
  1376. .LP
  1377. In the back of the book you'll find 
  1378. Appendix A, an alphabetical listing of all \*L routines.
  1379. .LP
  1380. .mc |
  1381. A companion document,
  1382. the \f2\*L Reference Supplement\f1, provides
  1383. system-specific material on \*L.
  1384. Separate versions of the \f2Supplement\f1 exist
  1385. for each operating system that \*L runs on.
  1386. The \f2\*L Reference Supplement\f1 begins with a section that describes
  1387. how to compile and link \*L code.
  1388. A number of short example programs, which illustrate
  1389. various \*L routines, follow.
  1390. The source code for the examples is supplied with your installation 
  1391. and may be compiled and run.
  1392. .mc
  1393. .H1 "Related Documents"
  1394. .Ih "documents, related"
  1395. The SYBASE document set includes a wide range of user guides and reference manuals,
  1396. which describe all aspects of the SYBASE relational database management system.
  1397. Because application development can draw on a number of different parts of the SYBASE system,
  1398. you may encounter most of the SYBASE document set at some time or another.
  1399. A few manuals, however, will prove to be particularly useful:
  1400. .Bl
  1401. \f2Commands Reference\f1 and \f2\*N User's Guide\f1 document the \*N
  1402. database language.
  1403. .Ih "Commands Reference"
  1404. .Ih "\*N User's Guide"
  1405. .Bl
  1406. \f2\*A User's Guide\f1 documents \*A, the editor used to create forms and
  1407. specify their processing.
  1408. .Ih "\*A User's Guide"
  1409. .Bl
  1410. \f2\*F Reference Manual\f1 describes the library of C functions that give an
  1411. application access to forms and their objects.
  1412. .Ih "\*F Reference Manual"
  1413. .Bz
  1414. .LP
  1415. In addition, versions of \*L and \*F are available for a number of other
  1416. languages, including COBOL, FORTRAN, Ada, and Pascal.  If you are interested in obtaining \*L
  1417. and \*F manuals for those languages, contact your SYBASE sales representative.
  1418. .Ih "COBOL/\*L"
  1419. .Ih "FORTRAN/\*L"
  1420. .Ih "Ada/\*L"
  1421. .Ih "Pascal/\*L"
  1422.